{{ partial "header.html" . }}

<div id="loadingMask" style="width: 100%; height: 100%; position: fixed; background: #fff;"></div>
<script>
function fadeOut(el) {
  el.style.opacity = 1;

  var last = +new Date();
  var tick = function() {
    el.style.opacity = +el.style.opacity - (new Date() - last) / 80;
    last = +new Date();
    // console.log(el.style.opacity);

    if (el.style.opacity > 0) {
      (window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16);
    } else {
      el.style.display='none';
    }
  };

  tick();
}

function ready(fn) {
    if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
         el = document.getElementById('loadingMask');
         fadeOut(el);
        var elements = document.querySelectorAll("img");
        Array.prototype.forEach.call(elements, function(el, i) {
            if (el.getAttribute("alt")) {
                const caption = document.createElement('figcaption');
                var node = document.createTextNode(el.getAttribute("alt"));
                caption.appendChild(node);
                const wrapper = document.createElement('figure');
                wrapper.className = 'image';
                el.parentNode.insertBefore(wrapper, el);
                el.parentNode.removeChild(el);
                wrapper.appendChild(el);
                wrapper.appendChild(caption);
            }
        });

    } else {
        document.addEventListener('DOMContentLoaded', fn);
    }
}
window.onload = ready;
</script>

<div class="content">
  <h1>{{ .Title }}</h1>
  {{ .Content }}

  <h2>Contributors</h2>
  {{ $scratch := newScratch }}
  {{ with .Site.GetPage "section" "author" }}
    <ol>
	{{ range .Pages }}
		{{ $author := .Params.author }}
		<li><a href="{{ .Permalink }}">{{ $author }}
		{{ $scratch.Set "author" $author }}
		{{ $counter := 0 }}
		{{ range where .Site.RegularPages ".Type" "posts" }}
			{{ if (or (eq .Params.author ( $scratch.Get "author" )) (in .Params.authors ( $scratch.Get "author")))}}
				{{ $counter = add $counter 1}}
			{{ end}}
		{{ end }}
		</a>
		({{ $counter }})
		</li>
	{{ end }}
	</ol>
  {{ end }}

</div>

<!--
{{ partial "latest_comments" . }}
-->

